/**
 * Created by Administrator on 2015/11/18.
 */
var mysql      = require('mysql');
var connection = mysql.createConnection({
    host     : 'localhost',
    user     : 'root',
    password : '',
    database : 'hibernate1'
});

connection.connect();

connection.query('SELECT * from article', function(err, rows, fields) {
    if (err) throw err;

    //console.log('The solution is: ', rows[0].solution);
    //console.log(rows);
    //console.log(fields);
    var datas = [];
    for(var row in rows){
        //console.log(rows[row].content);
        //console.log(typeof rows[row]);
        var node = {
            id:rows[row].id,
            text:rows[row].title
        }
        datas[row] = node;
    }
    console.log(JSON.stringify(datas));
});

connection.end();